package com.springcloud.servicefeign.service;

import com.springcloud.servicefeign.impl.SchedualServiceHiHystric;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author chenkuan
 * @version v1.0
 * @desc 定义一个feign接口
 * 通过@ FeignClient（“服务名”），来指定调用哪个服务。
 * 比如在代码中调用了service-hi服务的“/hi”接口
 * <p>
 * 实现短路器
 * 在FeignClient的SchedualServiceHi接口的注解中加上fallback的指定类
 * @date 2019/4/25 025 14:06
 */
@FeignClient(value = "service-hi", fallback = SchedualServiceHiHystric.class)
public interface SchedualServiceHi {

	/**
	 * service-hi的Controller接口中使用的@RequestMapping，
	 * 这里也要使用@RequestMapping(value = "name")，否则访问不到
	 * 这里的@RequestParam也是必须
	 */
	@RequestMapping(value = "/hi", method = RequestMethod.GET)
	String sayHiFromClientOne(@RequestParam(value = "name") String name);

}
